package cn.sumpu.app.guoguojie.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.*;
import cn.sumpu.app.guoguojie.dao.*;
import cn.sumpu.app.guoguojie.domain.*;
import cn.sumpu.app.guoguojie.exception.*;

public class DoingTagShowDaoImpl extends SqlSessionDaoSupport implements
		DoingTagShowDao {

	//添加前台标签
	@Override
	public void addDoingTagShow(DoingTagShow doingTagShow)
			throws AppBusinessException {
		try {
			getSqlSession()
					.insert("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.addDoingTagShow",
							doingTagShow);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("addDoingTagShow database failure.", e);
			}
			throw new AppBusinessException("addDoingTagShow database failure.", e);
		}
	}

	//更改前台标签
	@Override
	public void updateDoingTagShow(DoingTagShow doingTagShow)
			throws AppBusinessException {
		try {
			getSqlSession()
					.update("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.updateDoingTagShow",
							doingTagShow);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("updateDoingTagShow database failure.", e);
			}
			throw new AppBusinessException("updateDoingTagShow database failure.", e);
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<DoingTagShow> getDoingTagShow(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return getSqlSession()
					.selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingTagShow",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getDoingTagShow database failure.", e);
			}
			throw new AppBusinessException("getDoingTagShow database failure.", e);
		}
	}
	
	//根据父ID取得字节点
	@SuppressWarnings("unchecked")
	@Override
	public List<DoingTagShow> getDstByParentId(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return getSqlSession()
					.selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDstByParentId",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getDstByParentId database failure.", e);
			}
			throw new AppBusinessException("getDstByParentId database failure.", e);
		}
	}
	//根据ID查询标签
	@Override
	public DoingTagShow getDstById(Map<String, Object> map) throws AppBusinessException {
		try {
			return (DoingTagShow)getSqlSession()
					.selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDstById", map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getDstById database failure.", e);
			}
			throw new AppBusinessException("getDstById database failure.", e);
		}
	}
	//删除前台标签
	@Override
	public void deleteDoingTagShow(Map<String, Object> map)
			throws AppBusinessException {
		try {
			getSqlSession()
					.delete("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.deleteDoingTagShow", map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("deleteDoingTagShow database failure.", e);
			}
			throw new AppBusinessException("deleteDoingTagShow database failure.", e);
		}
	}

	// 查询格子屋的
	@SuppressWarnings("unchecked")
	@Override
	public List<Doing> getGridByCondition(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return (List<Doing>) getSqlSession()
					.selectList(
							"cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getGridByCondition",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getGridByCondition database failure.", e);
			}
			throw new AppBusinessException(
					"getGridByCondition database failure.", e);
		}
	}

	// 查询格子屋的记录数
	@Override
	public int getGridCount(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return (Integer) getSqlSession()
					.selectOne(
							"cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getGridCount",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getGridCount database failure.", e);
			}
			throw new AppBusinessException("getGridCount database failure.", e);
		}
	}

	// 查询格子屋最新
	@SuppressWarnings("unchecked")
	@Override
	public List<Doing> getGridNew(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return (List<Doing>) getSqlSession()
					.selectList(
							"cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getGridNew",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getGridNew database failure.", e);
			}
			throw new AppBusinessException("getGridNew database failure.", e);
		}
	}

	// 查询格子屋最新总记录数
	@Override
	public int getGridNewCount(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return (Integer) getSqlSession()
					.selectOne(
							"cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getGridNewCount",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getGridNewCount database failure.", e);
			}
			throw new AppBusinessException("getGridNewCount database failure.",
					e);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Doing> getGridBruce(int size) throws AppBusinessException {
		try {
			return (List<Doing>) getSqlSession()
					.selectList(
							"cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getGridBruce", size);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getGridBruce database failure.", e);
			}
			throw new AppBusinessException("getGridBruce database failure.",
					e);
		}
	}
	
	//查询微博的标签
    @SuppressWarnings("unchecked")
    @Override
    public List<String> getTagByDoing(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<String>) getSqlSession()
                    .selectList(
                            "cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getTagByDoing", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getTagByDoing database failure.", e);
            }
            throw new AppBusinessException("getTagByDoing database failure.",
                    e);
        }
    }
    //通过标签集合查询微博
    @SuppressWarnings("unchecked")
    @Override
    public List<Doing> getDoingByTags(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<Doing>) getSqlSession()
                    .selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingByTags", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingByTags database failure.", e);
            }
            throw new AppBusinessException("getDoingByTags database failure.",
                    e);
        }
    }
    //通过标签集合查询微博总数
    @Override
    public Integer getDoingCountByTags(Map<String, Object> map) throws AppBusinessException {
        try {
            return (Integer) getSqlSession()
                    .selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingCountByTags", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingCountByTags database failure.", e);
            }
            throw new AppBusinessException("getDoingCountByTags database failure.",
                    e);
        }
    }

    //查询我的分享
    @SuppressWarnings("unchecked")
    @Override
    public List<Doing> getDoingByMember(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<Doing>) getSqlSession()
                    .selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingByMember", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingByMember database failure.", e);
            }
            throw new AppBusinessException("getDoingByMember database failure.",
                    e);
        }
    }
    //查询我的分享总数
    @Override
    public Integer getDoingCountByMember(Map<String, Object> map) throws AppBusinessException {
        try {
            return (Integer) getSqlSession()
                    .selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingCountByMember", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingCountByMember database failure.", e);
            }
            throw new AppBusinessException("getDoingCountByMember database failure.",
                    e);
        }
    }

    //查询我的收藏
    @SuppressWarnings("unchecked")
    @Override
    public List<Doing> getDlByMember(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<Doing>) getSqlSession()
                    .selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDlByMember", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingByMember database failure.", e);
            }
            throw new AppBusinessException("getDoingByMember database failure.",
                    e);
        }
    }

    //查询我的收藏总数
    @Override
    public Integer getDlCountByMember(Map<String, Object> map) throws AppBusinessException {
        try {
            return (Integer) getSqlSession()
                    .selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDlCountByMember", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDlCountByMember database failure.", e);
            }
            throw new AppBusinessException("getDlCountByMember database failure.",
                    e);
        }
    }
    //查询话题微博
    @SuppressWarnings("unchecked")
    @Override
    public List<Doing> getDoingByDiscuss(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<Doing>) getSqlSession()
                    .selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingByDiscuss", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingByDiscuss database failure.", e);
            }
            throw new AppBusinessException("getDoingByDiscuss database failure.",
                    e);
        }
    }
    //查询话题微博总数
    @Override
    public Integer getDoingCountByDiscuss(Map<String, Object> map) throws AppBusinessException {
        try {
            return (Integer) getSqlSession()
                    .selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingCountByDiscuss", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingCountByDiscuss database failure.", e);
            }
            throw new AppBusinessException("getDoingCountByDiscuss database failure.",
                    e);
        }
    }

    //查询好店微博
    @SuppressWarnings("unchecked")
    @Override
    public List<Doing> getDoingBySnick(Map<String, Object> map) throws AppBusinessException {
        try {
            return (List<Doing>) getSqlSession()
                    .selectList("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingBySnick", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingBySnick database failure.", e);
            }
            throw new AppBusinessException("getDoingBySnick database failure.",
                    e);
        }
    }
    //查询好店微博总数
    @Override
    public Integer getDoingCountBySnick(Map<String, Object> map) throws AppBusinessException {
        try {
            return (Integer) getSqlSession()
                    .selectOne("cn.sumpu.app.guoguojie.persistence.DoingTagShowMapper.getDoingCountBySnick", map);
        } catch (Exception e) {
            if (logger.isErrorEnabled()) {
                logger.error("getDoingCountBySnick database failure.", e);
            }
            throw new AppBusinessException("getDoingCountBySnick database failure.",
                    e);
        }
    }
	
}
